<?php
namespace Home\Model;
use Think\Model;
class ProjectModel extends Model{
	private $_id;	// 考试项目唯一标识号
	private $_name;	// 考试项目的名称
	private $_examcenter;	// 考试所在考点，可以多个
	private $_major;	// 考试允许的专业，可以多个
	private $_title;	// 关于本场考试的说明
	private $_uptime;	// 最后更新时间
	private $_isopen;	// 考试项目是否开启，如不开启，前台不可见, 0表示不开启，1表示开启

	public function getOpenLists(){
		$res = $this->where(array('isopen'=>1))->limit(5)->select();
		return $res;
	}

	public function getLists($majors, $examcenter){
		$res = array();
		foreach($this->getOpenLists() as $v){
			$t = array_intersect($majors, explode(',', $v['major']));
			if(in_array($examcenter, explode(',', $v['examcenter']))
			&& !empty($t)){
				//dump($v);
				//$v['examcentername'] = implode(',', D('Examcenter')->getNames(explode(',' $v['examcenter'])));
				//$v['majorname'] = implode(',', D('Major')->getNames(explode(',' $v['major'])));
				$Examcenter = D('Examcenter');
				$Major = D('Major');
				$v['examcentername'] = implode(',', $Examcenter->getNames(explode(',', $v['examcenter'])));
				//$v['majorname'] = implode(',', $Major->getNames(explode(',' $v['major'])));	// 吡了狗
				$v['majorname'] = implode(',', $Major->getNames(explode(',', $v['major'])));
				$res[] = $v;
			}
		}
		return $res;
	}
}
